
from threading import Thread   # 多线程
from multiprocessing import Process   # 多进程

from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor  # 线程池， 进程池


def func1():
    for i in range(200):
        print('func1:', i)

# 多线程，多进程
# def func2():
#     for i in range(200):
#         print('func2:', i)
#
#
# if __name__ == '__main__':
#     t1 = Process(target=func1)
#     t2 = Thread(target=func2)
#     t1.start()
#
#     # func1()
#     # func2()
#
#     for i in range(200):
#         print('main:', i)


# 线程池，进程池
def func(name):
    for i in range(1000):
        print(name, i)


if __name__ == '__main__':
    # with ThreadPoolExecutor(50) as t:
    #     for i in range(50):
    #         t.submit(func, name='多线程')
    #
    # print('线程结束')
    with ProcessPoolExecutor(50) as r:
        for i in range(50):
            r.submit(func, name='多进程')

    print('进程结束')


